package com.lam.framework.mybatis;

import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.lam.common.utils.DateUtil;

@Component
public class LamMetaObjectHandler implements MetaObjectHandler {
	
	@Override
	public void insertFill(MetaObject metaObject) {
		this.setFieldValByName("createTime", DateUtil.newDate(), metaObject);
		this.setFieldValByName("createdAt", DateUtil.newDate(), metaObject);
	}

	@Override
	public void updateFill(MetaObject metaObject) {
		this.setFieldValByName("updateTime", DateUtil.newDate(), metaObject);
		this.setFieldValByName("updatedAt", DateUtil.newDate(), metaObject);
	}
}
